﻿using D.Traceability.Domain;
using D.Traceability.ErrorCode;
using D.Traceability.Write.API.APPlicant.Command;
using D.Traceability.Write.API.APPlicant.Command.BreedCommand;
using D.Traceability.Write.API.APPlicant.Command.DeepCommand;
using D.Traceability.Write.API.APPlicant.Command.SlaughterCommand;
using D.Traceability.Write.API.APPlicant.Command.TestCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Traceability.Write.API.Controllers
{
    /// <summary>
    /// 溯源管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceController : ControllerBase
    {
        private readonly IMediator mediator;

        public TraceController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加溯源信息
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddTraceModel(AddTraceCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        ///  批量删除溯源数据(逻辑删)
        /// </summary>
        [HttpDelete]
        public async Task<APIResult<string>> DeleteTrace([FromBody]DeleteTraceCommand request)
        { 
            return await mediator.Send(request);
        }


        /// <summary>
        /// 溯源单个对象反填(通过 -- 生产批次查询)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<SU_TraceabilityModel>> FanTianTrace([FromQuery]FanTianTraceCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改溯源单个对象(通过 -- 生产批次查询)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<string>> UpdateTrace(UpdateTraceCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加质检报道图片
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddTest(AddTestCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除质检报道图片
        /// </summary>
        [HttpGet]
        public async Task<APIResult<string>> DeleteTest([FromQuery] DeleteTestCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加养殖信息
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddBreed(AddBreedCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加保健信息
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddImmunity(AddImmunityCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改保健信息
        /// </summary>
        [HttpPut]
        public async Task<APIResult<string>> UpdateImmunity(UpdateImmunityCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除保健信息
        /// </summary>
        [HttpDelete]
        public async Task<APIResult<string>> DeleteImmunity([FromQuery]DeleteImmunityCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加/修改企业信息
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddUpdateEnterprise(AddUpdateEnterpriseCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加/修改屠宰信息-命令
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddUpdateSlaughter(AddUpdateSlaughterCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加/修改深加工信息-命令
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddUpdateDeep(AddUpdateDeepCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加/修改供应商信息-命令
        /// </summary>
        [HttpPost]
        public async Task<APIResult<string>> AddUpdateSupplier(AddUpdateSupplierCommand request)
        { 
            return await mediator.Send(request);
        }


    }
}
